<template>
	<hyb-page title="管理中心">
		<!-- 请开始您的开发 ~ -->
		<template v-slot:body>
			<view class="gui-bg-white gui-dark-bg-level-3 gui-padding gui-margin-top" v-for="(item,index) in items"
				@tap="to(item)">
				<view class="gui-list-items">
					<view class="gui-list-image gui-relative">
						<image class="gui-list-image" :src="item.img">
						</image>
						<view class="gui-badge-point" v-if="role[item.tag]"></view>
					</view>
					<view class="gui-list-body gui-border-b">
						<view class="gui-list-title">
							<text class="gui-list-title-text gui-primary-text">{{item.name}}</text>
							<!-- <text class="gui-list-title-desc gui-color-gray">{{role[item.tag]}}</text> -->
						</view>
						<text class="gui-list-body-desc gui-color-gray">{{item.desc}}</text>
					</view>
					<text class="gui-list-arrow-right gui-icons gui-color-gray-light">&#xe601;</text>
				</view>
			</view>
		</template>
	</hyb-page>
</template>
<script>
	export default {
		data() {
			return {
				role: {},
				base: {},

				items: [
					// {
					// 	img: "https://paidano2oer-1300612619.cos.ap-chengdu.myqcloud.com/images/6/2022/04/H3jd88jD9Jr3mKqRjtjRjumXZux5yu.png",
					// 	name: "商家",
					// 	desc: "BUSINESS",
					// 	tag: "shangjia"
					// }, 
					{
						img: "https://paidano2oer-1300612619.cos.ap-chengdu.myqcloud.com/images/6/2022/04/H3jd88jD9Jr3mKqRjtjRjumXZux5yu.png",
						name: this.$store.state.base.show_base.shifu_bie_ming,
						desc: "SHIFU",
						tag: 'jishi'
					},
					// {
					// 	img: "https://paidano2oer-1300612619.cos.ap-chengdu.myqcloud.com/images/6/2022/04/H3jd88jD9Jr3mKqRjtjRjumXZux5yu.png",
					// 	name: "员工",
					// 	desc: "STAFF",
					// 	tag: "yuangong"
					// },
					// {
					// 	img: "https://paidano2oer-1300612619.cos.ap-chengdu.myqcloud.com/images/6/2022/04/H3jd88jD9Jr3mKqRjtjRjumXZux5yu.png",
					// 	name: "分销商",
					// 	desc: "DISTRIBUTOR",
					// 	tag: 'fenxiao'

					// },
					// {
					// 	img: "https://paidano2oer-1300612619.cos.ap-chengdu.myqcloud.com/images/6/2022/04/H3jd88jD9Jr3mKqRjtjRjumXZux5yu.png",
					// 	name: "代理商",
					// 	desc: "AGENT",
					// 	tag: 'daili'
					// }
				],
			}
		},

		created() {
			uni.gPost("user/role").then((role) => {
				this.role = role;
				console.log(this.role)
			})
		},

		methods: {
			to(item) {
				let tag = item.tag;
				let role = this.role[tag];

				if (tag == "jishi") {
					
					if (role) {
						if(role.y_styles == "待审核"){
							uni.showModal({
								title:"审核中",
								content:"您信息还在审核中，是否进行修改?",
								success:(res)=>{
									if(res.confirm){
										uni.gJs.navigate("/hyb_o2o/jishi/ruzhu/ruzhu");
									}
								}
							})
							return;
						}
						uni.storage.set(tag,role);
						uni.gJs.navigate("/hyb_o2o/jishi/mine/mine");
					} else {
						uni.showModal({
							title:"申请入驻",
							content:"您还没有入驻，是否立即申请入驻?",
							success:(res)=>{
								if(res.confirm){
									uni.gJs.navigate("/hyb_o2o/jishi/ruzhu/ruzhu");
								}
							}
						})
					}
				}if (tag == "yuangong") {
					if (role) {
						uni.gJs.navigate("/hyb_o2o/jishi/mine/mine");
					} else {
						uni.showModal({
							title:"申请入驻",
							content:"您还没有入驻，是否申请入驻?",
							success:(res)=>{
								if(res.confirm){
									uni.gJs.navigate("/hyb_o2o/jishi/ruzhu/ruzhu");
								}
							}
						})
					}
				}
			},

		}
	}
</script>
<style scoped>
	.gui-list-image {
		height: 120rpx;
		width: 120rpx;
	}
</style>
